import {getApi,postApi} from '../request'
import {PullCommentsListRequestData,GetCommentsListRequestData} from './types'
//上传评论
export async function commentPull(data:PullCommentsListRequestData) {

    if (data.article_id.length<8  || data.content.length<5 || data.isMain.length === 0)
     { console.log("提交数据不符合要求！！！"); return "data-0000"; }

    try {
      const res = await postApi('comment/pull',{

        "article_id":data.article_id,
        "comment_id":data.comment_id,
	      "content":data.content,
        "isMain":data.isMain

      });
      return res;
  
    } catch (error) {
      console.error(error); // 处理错误
      return "error-0000"
    }
  }

  //获取全部评论
export async function commentGetList(data:GetCommentsListRequestData) {

    if (data.article_id.length<8 )
     { console.log("提交数据不符合要求！！！"); return "data-0000"; }

    try {
      const res = await getApi('comment/getList',{
        "article_id":data.article_id,
      });
      return res;
  
    } catch (error) {
      console.error(error); // 处理错误
      return "error-0000"
    }
  }